﻿using System;
using DevelopTool.Bll;
using DevelopTool.Common;
using DevelopTool.Forms.BaseForms;
using DevelopTool.Model.CommonModels;

namespace DevelopTool.Forms.CommonForms
{
    /// <summary>
    /// 属性窗口
    /// </summary>
    public partial class ShowAttributeForm : BaseUIForm
    {
        public BaseBll BaseBll;

        private ManageMenu manageMenu;

        private int id;

        public ShowAttributeForm(int id)
        {
            InitializeComponent();

            this.id = id;
        }

        private void ShowAttributeForm_Load(object sender,EventArgs e)
        {
            if(BaseBll != null)
            {
                this.manageMenu = BaseBll.Get(this.id);
            }

            if(manageMenu != null)
            {
                string title = manageMenu.NodeName + "-属性";
                string msg = $"创建时间：{manageMenu.CreateTime}\r\n\r\n修改时间：{manageMenu.UpdateTime}";
                string remark = manageMenu.Remark;

                this.Text = title;
                this.uiLabel.Text = msg;
                this.txtRemark.Text = remark;
            }

            ThemHelper.SetSystemThem(this);
        }

        private void txtRemark_TextChanged(object sender,EventArgs e)
        {
            if(manageMenu != null && BaseBll != null)
            {
                BaseBll.SetRemark(manageMenu.Id,this.txtRemark.Text);
            }
        }

    }
}
